/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package de.editura.oxygen.severin.imageviewer.features;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author kschmidtner
 */
public class ImagePathAdministration {
    
    public static final String OXYGEN_EXTENSION_DIR = "/OxygenExtension/SeverinImageViewer/";
    public static final String LAST_IMG_PATHSTXT = "lastImgPaths.txt";

    private List<String> lastimgPaths = new ArrayList<String>();

    public ImagePathAdministration() throws FileNotFoundException, IOException {
        loadLastImgPaths();
    }


    public void loadLastImgPaths () throws FileNotFoundException, IOException {

        File imgPathsDir = new File(System.getProperty("user.home") + OXYGEN_EXTENSION_DIR);
        File imgPathsFile = new File(imgPathsDir, LAST_IMG_PATHSTXT);

        if (!imgPathsDir.exists()) {
            imgPathsDir.mkdirs();
        }

        if (!imgPathsFile.exists()) {
            ImagePathWriter.createImgPathFile(imgPathsFile);
        }

        BufferedReader br = new BufferedReader(new FileReader(imgPathsFile));
        String line = "";

        while ((line = br.readLine()) != null) {
            lastimgPaths.add(line);
        }
        br.close();
    }

    public List<String> getLastimgPaths() {
        return lastimgPaths;
    }

    public void setLastimgPaths(List<String> lastimgPaths) {
        this.lastimgPaths = lastimgPaths;
    }

    


}
